package com.example.rabbitmq.job;


import com.example.rabbitmq.producer.TopicMsgProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时发送消息
 * @date 2019-4-8 12:23:44
 * @author joker
 */
@Component
@EnableScheduling
public class TopicTimeJob {

    private TopicMsgProducer producer;

    @Autowired
    public TopicTimeJob(TopicMsgProducer producer) {
        this.producer = producer;
    }


    @Scheduled(cron = "0/15 * * * * ?")
    public void test(){
        int a = 10;
        for (int i = 0; i < a; i++){
            producer.sendTopicMsg("A这个是我发送的消息：" + i);
            producer.sendTopicMsgB("B这个是我发送的消息：" + i);
        }
    }
}
